package Chapter6.dao;

import org.hibernate.HibernateException;

import Chapter6.table_per_class.Book_C6_Table_Per_Class;
import Chapter6.table_per_class.Detail_Book_C6_Table_Per_Class;

import learnning.dao.base.HibernateDao;

public class Book_Table_Per_ClassDao extends HibernateDao {
	public void add(String name, String author, long idDetail) {
		try {
			begin();
			Detail_Book_C6_Table_Per_Class detail = new Detail_Book_C6_Table_Per_Class(
					author);
			detail.setName(name);
			detail.setId(idDetail);
			getSession().save(detail);
			Book_C6_Table_Per_Class book = new Book_C6_Table_Per_Class(name);
			book.setId(5l);
			getSession().save(book);
			commit();
		} catch (HibernateException e) {
			rollback();
			e.printStackTrace();
		}
	}
}
